/*
 * @lc app=leetcode.cn id=942 lang=javascript
 *
 * [942] 增减字符串匹配
 */

// @lc code=start
/**
 * @param {string} S
 * @return {number[]}
 */
var diStringMatch = function(S) {
    let arr=[0]
    let countI=0
    let countD=0
    for(let i=0;i<S.length;i++){
        if(S[i]=="I"){countI++;arr.push(countI)}
        else{
            countD++
            arr.push(-countD)
        }
    }
    return arr.map((i)=>i+countD)
};
// @lc code=end

